package com.wms.controller;

import com.wms.bean.PageBean;
import com.wms.bean.ResultBean;
import com.wms.core.R;
import com.wms.dto.ReportLossesDetail;
import com.wms.entity.ReportLosses;
import com.wms.service.ReportLossesDetailService;
import com.wms.service.ReportLossesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "skh-报损管理")
public class ReportLossesController {
    @Autowired
    ReportLossesService reportLossesService;
    
    @Autowired
    ReportLossesDetailService reportLossesDetailService;

    @GetMapping("/reportLosses/queryAllReportLosses")
    @ApiOperation("查询报损列表")
    public ResultBean<PageBean<ReportLosses>> queryAllReportLosses(@RequestParam int page,int pageSize){
        PageBean pageBean =reportLossesService.queryAllReportLosses(page,pageSize);
        if (pageBean!=null){
            return R.success("查询成功",pageBean);
        }
        return R.fail("查询失败");
    }

    @GetMapping("/getReportLossesDetailByCode")
    @ApiOperation(value = "报损详情")
    public ResultBean getReportLossesDetailByCode(String breakageCode){
        ReportLossesDetail reportLossesDetail = reportLossesDetailService.getReportLossesDetailByCode(breakageCode);
        if (reportLossesDetail != null){
            return R.success("查询成功",reportLossesDetail);
        }
        return R.fail("查询失败");
    }
}
